# -*- coding: utf-8 -*-
from web.controllers.api import route_api
from  flask import request,jsonify,g
from common.models.grade import Grade

# from common.models.member.Member import Member
from common.libs.UrlManager import UrlManager
# from common.libs.Helper import getCurrentDate,getDictFilterField,selectFilterObj
# from application import app,db
from sqlalchemy import  or_
@route_api.route("/Grade/index" )
def GradeIndex():
    # return
    resp = { 'code':200 ,'msg':'操作成功~','data':{} }

    food_list = Grade.query.filter_by(status=1) \
        .order_by(Grade.grade.desc()).all()

    data_food_list = []
    if food_list:
        for item in food_list:
            tmp_data = {
                'id':item.id,
                'user_name':UrlManager.buildUrl(item.user_name),
                'book_name': UrlManager.buildUrl(item.book_name),
                'grade': UrlManager.buildUrl(item.grade),
            }
            data_food_list.append( tmp_data )

    resp['data']['banner_list'] = data_food_list
    return jsonify( resp )